import Component from "../../core/Component";
import { ComponentInterface } from "../../core/Component";

export default class H5Compnent extends Component {
  element: HTMLDivElement
  backgroundColor?: string
   constructor(options: {
      child?: ComponentInterface
      backgroundColor?: string
      x?: number
      y?: number
      width?: number
      height?: number
    }) {
      super(options)
      this.backgroundColor = options.backgroundColor
    }

    async init(): Promise<void> {
      this.element = document.createElement('div')
      document.body.appendChild(this.element)
      await super.init()
    }
  
    async resize(): Promise<void> {
      super.resize()
      this.element.style.width = this.width + 'px'
      this.element.style.height = this.height + 'px'
      this.element.style.top = this.screenY + 'px'
      this.element.style.left = this.screenX + 'px'
      this.element.style.position = 'absolute'
      this.element.style.backgroundColor = this.backgroundColor
    }
}